package com.record.service.serviceImpl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.record.entity.Forbiddent;
import com.record.service.ForbiddentService;

import com.record.mapper.ForbiddentMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
* @author 26292
* @description 针对表【forbiddent(违禁词表)】的数据库操作Service实现
* @createDate 2024-05-12 15:48:23
*/
@Service
public class ForbiddentServiceImpl extends ServiceImpl<ForbiddentMapper, Forbiddent>
    implements ForbiddentService {

    @Override
    public List<String> getForbiddenList() {
        return baseMapper.getAllWord();
    }

    @Override
    public Boolean isForbidden(String value) {
        List<String> forbiddenList = getForbiddenList();
        if(CollectionUtils.isEmpty(forbiddenList)){
            return false;
        }
        //我真是你TM    -》  你TM
        for (String word : forbiddenList) {
            if(value.contains(word)){
                return true;
            }
        }
        return false;
    }
}




